<?PHP
		function println($string_message = '') {
			return isset($_SERVER['SERVER_PROTOCOL']) ? print "$string_message<br />" . PHP_EOL:
				print $string_message . PHP_EOL;
		}
		function db_escape_string($text) {
			if (function_exists('mb_detect_encoding')) {
				$cur_encoding = mb_detect_encoding($text);
				if(($cur_encoding != "UTF-8" && $cur_encoding != "ASCII") || !mb_check_encoding($text, "UTF-8")) 
					$text = utf8_encode($text);
			}
			return mysql_real_escape_string($text);
		}
		function curPageName() {
			return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
		}
		function curPageURL() {
			 return "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
		}
		/**
		* This function can be used to check the sanity of variables
		*
		* @access private
		*
		* @param string $type  The type of variable can be bool, float, numeric, string, array, or object
		* @param string $string The variable name you would like to check
		* @param string $length The maximum length of the variable
		*
		* return bool
		*/
		function sanityCheck($string, $type, $length){
			// assign the type
			$type = 'is_'.$type;
			if(!$type($string)) return FALSE;
			elseif(empty($string)) return FALSE;
			elseif(strlen($string) > $length) return FALSE;
			else{
				// if all is well, we return TRUE
				return TRUE;
			}
		}
		
		function barcodeLengthCheck($barcode, $length) {
			if (strlen($barcode) != $length) return FALSE;
			return TRUE;
		}
		
		function checkSet_FormAddInventory() {
			return(isset($_POST['itemname']) and isset($_POST['cat']) and isset($_POST['man']) and isset($_POST['bar'])
					and isset($_POST['cstock']) and isset($_POST['price']) and isset($_POST['mstock']) and isset($_POST['bundleunit']));
		}
		
		function checkSet_FormAddShop() {
			return(isset($_POST['shopname'], $_POST['loc'], $_POST['add']));
		}
?>